home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr18 / mrun210.zip / MRUN210.WAS < prev    next >
Text File  |  1993-04-28  |  34KB  |  1,040 lines

  1. ;MailRun v2.10:  Automated BBS Communications
  2. ;1992-1993 Gerald P. Sully, all rights reserved.
  3.  
  4.  
  5. #comment
  6. **************************************************************************
  7. **************************************************************************
  8. * The source code for MailRun is contained in 9 separate files: 
  9. * MRUN210.WAS (this file), MRUN210.H (a header file), and files 
  10. * named MRUN210?.WAS, where ? is a letter A through G.  MailRun
  11. * also requires the file MRUNICON.DLL in order to display the 
  12. * tool bar.
  13. * MRUN210.WAS is the script from which the other script files
  14. * are run.  It performs a brief initialization to find the
  15. * location of its support files, then chains to MRUN210A.WAS,
  16. * which is the principle engine of MailRun.  It will also 
  17. * perform an install routine if it finds that there is no
  18. * current MAILRUN.INI file.
  19. * The key files of MailRun are the *.MRN files.  These
  20. * store configuration information and control what tasks
  21. * will be performed on each BBS.  The user interface is
  22. * designed to provide a convenient way to edit these files
  23. * and display their contents.  The files are standard INI
  24. * files, and so may also be edited by hand.  The comm engine,
  25. * contained in MRUN210G.WAS, reads the currently loaded *.MRN
  26. * file, calls each BBS and executes each pending task.
  27. **************************************************************************
  28. **************************************************************************
  29. #endcomment
  30.  
  31.  
  32. #define IniFile 0
  33.  
  34. string MailRunIni, MailRunList, MailRunTrunc, MailRun, OldIni
  35. string MailRunDir, MailDir, ReplyDir, DownloadDir, UploadDir, TempDir
  36. string DialAttempts, DialTimeout, DialPause, IdleTimeout, SavePackets
  37. string Archiver, QWKReader, LogViewer
  38. integer LogRun, AppendLog, AnsiInLog, NewfileFilter, HelpPage
  39. float Version
  40.  
  41.  
  42. #comment
  43. *********************************************************************
  44. * MAIN()
  45. * Calls makefullname(), checkdir(), makeini(), gettempdir(),
  46. * delspec(), changesettings(), movedir(), updatemrn()
  47. * Executes MRUN210A.WAX
  48. * Checks for existence of MAILRUN.INI file, then chains
  49. * to the main body of the script.
  50. *********************************************************************
  51. #endcomment
  52.  
  53. proc main
  54. string MRunMain, temp, MailRunHelp
  55.     MailRunHelp = makefullname($PWTASKPATH, "mailrun.hlp")
  56.     if isfile MailRunHelp
  57.         set aspect helpfile "mailrun.hlp"
  58.     endif
  59.  
  60.    ;Create the temporary directory
  61.    gettempdir()
  62.    if !(checkdir(TempDir, ""))
  63.       halt
  64.    endif
  65.    
  66.    MailRunIni = makefullname($WINPATH, "MAILRUN.INI")
  67.    profilerd MailRunIni "MailRun" "Version" temp
  68.    atof temp Version
  69.    if Version != 2.10
  70.       ;if there is no .INI file for version 2.10, run install procedure
  71.         fetch aspect scriptpath temp
  72.        temp = makefullname(temp, "mailrun.hlp")
  73.        if not strcmpi MailRunHelp temp
  74.            copyfile temp MailRunHelp
  75.            delfile temp
  76.         endif
  77.         set aspect helpfile "mailrun.hlp"
  78.       makeini()
  79.       changesettings()
  80.       movedir()
  81.       updatemrn()
  82.         delfile OldIni
  83.       statmsg "Installation complete!"
  84.    endif
  85.  
  86.    ;Make sure the Temp directory is empty
  87.    delspec(TempDir, "*.*")
  88.    profilerd MailRunIni "MailRun" "MailRunDir" MailRunDir
  89.    MRunMain = makefullname(MailRunDir, "MRUN210A")
  90.    execute MRunMain
  91. endproc
  92.  
  93.  
  94. #comment
  95. *********************************************************************
  96. * DELSPEC()
  97. * Called by main()
  98. * Calls makefullname()
  99. * Deletes specified filespec from specified directory.
  100. *********************************************************************
  101. #endcomment
  102.  
  103. proc delspec
  104. strparm dirname, spec
  105. string filename, filespec
  106.    FileSpec = makefullname(dirname, spec)
  107.    findfirst FileSpec
  108.    while FOUND
  109.       FileName = makefullname(dirname, $FILENAME)
  110.       delfile FileName
  111.       findnext
  112.    endwhile
  113. endproc
  114.  
  115.  
  116. #comment
  117. *********************************************************************
  118. * MAKEINI()
  119. * Called by main()
  120. * Calls welcomebox(), getbbstypes()
  121. * Creates the MAILRUN.INI file and sets default values.
  122. *********************************************************************
  123. #endcomment
  124.  
  125. proc makeini
  126. string StateDLPath, StateULPath, AspectDir, temp, MailRunBak
  127. integer dialogstatus
  128. integer StateWaitCnct, StateCallPause, StateMaxDial
  129.    welcomebox()
  130.    ;Check whether user wishes to continue
  131.    while 1
  132.        dialogstatus = $DIALOG
  133.       switch dialogstatus
  134.           case 1
  135.               ;user chose Cancel
  136.               halt
  137.           endcase
  138.           case 10
  139.               ;user chose OK
  140.               exitwhile
  141.           endcase
  142.       endswitch
  143.    endwhile
  144.  
  145.     ;Save the old MAILRUN.INI file if it exists
  146.  
  147.     if isfile MailRunIni
  148.         OldIni = makefullname(TempDir, "oldini.tmp")
  149.         copyfile MailRunIni OldIni
  150.         MailRunBak = makefullname($WINPATH, "MAILRUN.BAK")
  151.         if isfile MailRunBak
  152.             delfile MailRunBak
  153.         endif
  154.         rename MailRunIni MailRunBak
  155.     endif        
  156.  
  157.    ;Create the file MAILRUN.INI
  158.  
  159.    fopen IniFile MailRunIni CREATE TEXT
  160.    if FAILURE
  161.       errormsg "Unable to create MAILRUN.INI;`r`nscript aborted...."
  162.       halt
  163.    endif 
  164.    fputs IniFile "[MailRun]"
  165.    fputs IniFile "Version=2.10"
  166.    fputs IniFile "MailRun="
  167.    fputs IniFile "MailRunDir="
  168.    fputs IniFile "MailDir="
  169.    fputs IniFile "ReplyDir="
  170.    fputs IniFile "DownloadDir="
  171.    fputs IniFile "UploadDir="
  172.    fputs IniFile "DialAttempts="
  173.    fputs IniFile "DialTimeout="
  174.    fputs IniFile "DialPause="
  175.    fputs IniFile "IdleTimeout="
  176.    fputs IniFile "SavePackets="
  177.    fputs IniFile "LogRun="
  178.    fputs IniFile "AppendLog="
  179.    fputs IniFile "AnsiInLog="
  180.    fputs IniFile "NewfileFilter="
  181.    fputs IniFile "Archiver="
  182.    fputs IniFile "QWKReader="
  183.    fputs IniFile "LogViewer="
  184.    fputs IniFile "DLSortField=0"
  185.    fputs IniFile "ULSortField=0"
  186.    fputs IniFile "DLPurgeLimit=0"
  187.    fputs IniFile "ExecTime=HH:MM:SS"
  188.    fputs IniFile "AutoRun=0"
  189.    fputs IniFile "GoWait=1"
  190.    fputs IniFile "PostRun=1"
  191.    fputs IniFile "RingInterrupt=1"
  192.    fputs IniFile ""
  193.    fputs IniFile "[BBSTypes]"
  194.    fputs IniFile "BBSType_1=PCBoard 14.5"
  195.    fputs IniFile "BBSType_2=PCBoard 15.0"
  196.    fputs IniFile "BBSType_3=WildCat! 3.6"
  197.    fputs IniFile "BBSType_4=Auntie"
  198.    fputs IniFile "BBSType_5=RBBS"
  199.    fputs IniFile ""
  200.    fputs IniFile "[MailDoors]"
  201.    fputs IniFile "MailDoor_1=QMail"
  202.    fputs IniFile "MailDoor_2=MarkMail"
  203.    fputs IniFile "MailDoor_3=Cam-Mail"
  204.    fputs IniFile "MailDoor_4=RoseMail"
  205.    fputs IniFile "MailDoor_5=TomCat"
  206.    fputs IniFile "MailDoor_6=Auntie Mail"
  207.    fputs IniFile "MailDoor_7=KingMail"
  208.    fputs IniFile "MailDoor_8=Mail Manager"
  209.    fputs IniFile ""
  210.    fputs IniFile "[DEFAULT]"
  211.    fputs IniFile "BBSName="
  212.    fputs IniFile "BBSType=PCBoard 14.5"
  213.    fputs IniFile "MailDoorType=KingMail"
  214.    fputs IniFile "Number_1="
  215.    fputs IniFile "Number_2="
  216.    fputs IniFile "Number_3="
  217.    fputs IniFile "UserName="
  218.    fputs IniFile "PWord="
  219.    fputs IniFile "UserResp1="
  220.    fputs IniFile "UserResp2="
  221.    fputs IniFile "XferProt=ZModem"
  222.    fputs IniFile "MailXferProt=ZModem"
  223.    fputs IniFile "QWKArchiver=pkunzip.exe"
  224.    fputs IniFile "LangNumber="
  225.    fputs IniFile "GraphicsOn=1"
  226.    fputs IniFile "LangPrompt=Language"
  227.    fputs IniFile "GraphicsPrompt=graphics (Enter)"
  228.    fputs IniFile "NamePrompt=first name"
  229.    fputs IniFile "PWordPrompt=Password"
  230.    fputs IniFile "UserPrompt1="
  231.    fputs IniFile "UserPrompt2="
  232.    fputs IniFile "ScanPrompt=Last Read"
  233.    fputs IniFile "ViewPrompt=View"
  234.    fputs IniFile "MorePrompt=More?"
  235.    fputs IniFile "FilePrompt="
  236.    fputs IniFile "ContinuePrompt=Continue"
  237.    fputs IniFile "CommandPrompt=Command?"
  238.    fputs IniFile "DLPrompt=Aborts Transfer"
  239.    fputs IniFile "DLUnavPrompt=(Enter)=none"
  240.    fputs IniFile "ULPrompt=Aborts Transfer"
  241.    fputs IniFile "ULDescPrompt=? ("
  242.    fputs IniFile "MsgMenuPrompt="
  243.    fputs IniFile "MailDoor=KM"
  244.    fputs IniFile "MailPrompt=KingMail Command"
  245.    fputs IniFile "ReceiveQWKPrompt=When Done"
  246.    fputs IniFile "MailDLPrompt=Aborts Transfer"
  247.    fputs IniFile "MailULPrompt=Aborts Transfer"
  248.    fputs IniFile ""
  249.    fputs IniFile "[PCBoard 14.5]"
  250.    fputs IniFile "GraphicsOn=1"
  251.    fputs IniFile "MailDoorType=KingMail"
  252.    fputs IniFile "LangPrompt=Language"
  253.    fputs IniFile "GraphicsPrompt=graphics (Enter)"
  254.    fputs IniFile "NamePrompt=first name"
  255.    fputs IniFile "PWordPrompt=Password"
  256.    fputs IniFile "ScanPrompt=Last Read"
  257.    fputs IniFile "ViewPrompt=View"
  258.    fputs IniFile "MorePrompt=More?"
  259.    fputs IniFile "ContinuePrompt=Continue"
  260.    fputs IniFile "CommandPrompt=Command?"
  261.    fputs IniFile "DLPrompt=Aborts Transfer"
  262.    fputs IniFile "DLUnavPrompt=(Enter)=none"
  263.    fputs IniFile "ULPrompt=Aborts Transfer"
  264.    fputs IniFile "ULDescPrompt=? ("
  265.    fputs IniFile ""
  266.    fputs IniFile "[PCBoard 15.0]"
  267.    fputs IniFile "GraphicsOn=1"
  268.    fputs IniFile "MailDoorType=KingMail"
  269.    fputs IniFile "UserResp1=n"
  270.    fputs IniFile "UserPrompt1=Personal Mail"
  271.    fputs IniFile "LangPrompt=Language"
  272.    fputs IniFile "GraphicsPrompt=graphics (Enter)"
  273.    fputs IniFile "NamePrompt=first name"
  274.    fputs IniFile "PWordPrompt=Password"
  275.    fputs IniFile "ScanPrompt=Last Read"
  276.    fputs IniFile "ViewPrompt=View"
  277.    fputs IniFile "MorePrompt=More?"
  278.    fputs IniFile "ContinuePrompt=Continue"
  279.    fputs IniFile "CommandPrompt=Command?"
  280.    fputs IniFile "DLPrompt=Aborts Transfer"
  281.    fputs IniFile "DLUnavPrompt=(Enter)=none"
  282.    fputs IniFile "ULPrompt=Aborts Transfer"
  283.    fputs IniFile "ULDescPrompt=? ("
  284.    fputs IniFile ""
  285.    fputs IniFile "[WildCat! 3.6]"
  286.    fputs IniFile "MailDoorType=TomCat"
  287.    fputs IniFile "CallingFrom=City"
  288.    fputs IniFile "UserResp1=Birth Date"
  289.    fputs IniFile "UserResp2=Telephone"
  290.    fputs IniFile "GraphicsOn=0"
  291.    fputs IniFile "NamePrompt=first name"
  292.    fputs IniFile "PWordPrompt=Password"
  293.    fputs IniFile "UserPrompt1=Birth Date"
  294.    fputs IniFile "UserPrompt2=phone"
  295.    fputs IniFile "ScanPrompt=Last Read"
  296.    fputs IniFile "ViewPrompt=View"
  297.    fputs IniFile "MorePrompt=[S]top"
  298.    fputs IniFile "FilePrompt=FILE MENU"
  299.    fputs IniFile "ContinuePrompt=ontinue"
  300.    fputs IniFile "CommandPrompt=MAIN MENU"
  301.    fputs IniFile "DLPrompt=Please begin"
  302.    fputs IniFile "DLUnavPrompt=file # 1"
  303.    fputs IniFile "ULPrompt=Please begin"
  304.    fputs IniFile "ULDescPrompt=Description?"
  305.    fputs IniFile ""
  306.    fputs IniFile "[Auntie]"
  307.    fputs IniFile "GraphicsOn=0"
  308.     fputs IniFile "UserResp1=^C"
  309.     fputs IniFile "UserResp2=3"
  310.    fputs IniFile "MailDoorType=Auntie Mail"
  311.    fputs IniFile "NamePrompt=first name"
  312.    fputs IniFile "PWordPrompt=Password"
  313.     fputs IniFile "UserPrompt1=select the one"
  314.     fputs IniFile "UserPrompt2=Choice (1, 2 or 3)"
  315.    fputs IniFile "ViewPrompt=Bulletin:"
  316.    fputs IniFile "FilePrompt=Files Area"
  317.    fputs IniFile "ContinuePrompt=Continue"
  318.    fputs IniFile "CommandPrompt=Main Area"
  319.    fputs IniFile "DLPrompt=Ctrl+X"
  320.    fputs IniFile "DLUnavPrompt=Enter date"
  321.    fputs IniFile "ULPrompt=Ctrl+X"
  322.    fputs IniFile "ULDescPrompt=1 ?"
  323.    fputs IniFile ""
  324.    fputs IniFile "[RBBS]"
  325.    fputs IniFile "GraphicsOn=0"
  326.    fputs IniFile "MailDoorType=Mail Manager"
  327.    fputs IniFile "NamePrompt=first name"
  328.    fputs IniFile "PWordPrompt=Password"
  329.    fputs IniFile "UserResp1=n"
  330.    fputs IniFile "UserPrompt1=Review new files"
  331.    fputs IniFile "ScanPrompt=Check"
  332.    fputs IniFile "ViewPrompt=new bulletins"
  333.    fputs IniFile "MorePrompt=More"
  334.    fputs IniFile "FilePrompt=FILE Command"
  335.    fputs IniFile "ContinuePrompt=Continue"
  336.    fputs IniFile "CommandPrompt=Main Command"
  337.    fputs IniFile "DLPrompt=for transfer"
  338.    fputs IniFile "DLUnavPrompt=[ENTER] quits"
  339.    fputs IniFile "ULPrompt=for transfer"
  340.    fputs IniFile "ULDescPrompt=+----+|"
  341.    fputs IniFile ""
  342.    fputs IniFile "[KingMail]"
  343.    fputs Inifile "MailDoor=KM"
  344.    fputs IniFile "MailPrompt=KingMail Command"
  345.    fputs IniFile "ReceiveQWKPrompt=When Done"
  346.    fputs IniFile "MailDLPrompt=Aborts Transfer"
  347.    fputs IniFile "MailULPrompt=Aborts Transfer"
  348.    fputs IniFile ""
  349.    fputs IniFile "[QMail]"
  350.    fputs IniFile "MailDoor=QM"
  351.    fputs IniFile "MailPrompt=QMail Command"
  352.    fputs IniFile "ReceiveQWKPrompt=these messages"
  353.    fputs IniFile "MailDLPrompt=Prepare to download"
  354.    fputs IniFile "MailULPrompt=Prepare to upload"
  355.    fputs IniFile ""
  356.    fputs IniFile "[MarkMail]"
  357.    fputs Inifile "MailDoor=MM"
  358.    fputs IniFile "MailPrompt=MarkMail Command"
  359.    fputs IniFile "ReceiveQWKPrompt=When Done"
  360.    fputs IniFile "MailDLPrompt=Aborts Transfer"
  361.    fputs IniFile "MailULPrompt=Aborts Transfer"
  362.    fputs IniFile ""
  363.    fputs IniFile "[RoseMail]"
  364.    fputs IniFile "MailDoor=RM"
  365.    fputs IniFile "MailPrompt=RoseMail Command"
  366.    fputs IniFile "ReceiveQWKPrompt=this Packet"
  367.    fputs IniFile "MailDLPrompt=Prepare to download"
  368.    fputs IniFile "MailULPrompt=Prepare to upload"
  369.    fputs IniFile ""
  370.    fputs IniFile "[Cam-Mail]"
  371.    fputs IniFile "MailDoor=CM"
  372.    fputs IniFile "MailPrompt=Cam-Mail Command"
  373.    fputs IniFile "ReceiveQWKPrompt=these messages"
  374.    fputs IniFile "MailDLPrompt=Prepare to upload"
  375.    fputs IniFile "MailULPrompt=Start your transfer"
  376.    fputs IniFile ""
  377.    fputs IniFile "[TomCat]"
  378.    fputs IniFile "MailDoor=T"
  379.    fputs IniFile "MsgMenuPrompt=MESSAGE MENU"
  380.    fputs IniFile "MailPrompt=TOMCAT MENU"
  381.    fputs IniFile "ReceiveQWKPrompt=when done"
  382.    fputs IniFile "MailDLPrompt=Start your"
  383.    fputs IniFile "MailULPrompt=Start your"
  384.    fputs IniFile ""
  385.    fputs IniFile "[Auntie Mail]"
  386.    fputs IniFile "MailDoor="
  387.    fputs IniFile "MailPrompt="
  388.    fputs IniFile "ReceiveQWKPrompt="
  389.    fputs IniFile "MailDLPrompt=Ctrl+X"
  390.    fputs IniFile "MailULPrompt=Ctrl+X"
  391.    fputs IniFile ""
  392.    fputs IniFile "[Mail Manager]"
  393.    fputs IniFile "MailDoor=d;mail"
  394.    fputs IniFile "MailPrompt=Your choice"
  395.    fputs IniFile "ReceiveQWKPrompt=this packet"
  396.    fputs IniFile "MailDLPrompt=Ready to send"
  397.    fputs IniFile "MailULPrompt=Ready to receive"
  398.    fclose IniFile
  399.    MailRun = MailRunIni
  400.  
  401.     if isfile OldIni
  402.         ;if there was a previous version of MailRun installed,
  403.         ;read the default values from the old file.
  404.         
  405.         ;don't offer the Aspect directory as a default for MailRunDir
  406.         profilerd OldIni "MailRun" "MailRunDir" MailRunDir
  407.         temp = makefullname(MailRunDir, "*")
  408.         fetch aspect scriptpath AspectDir
  409.         addfilename AspectDir "*"
  410.         if strcmpi temp AspectDir
  411.             MailRunDir = makefullname($PWTASKPATH, "mailrun")
  412.         endif
  413.  
  414.         profilerd OldIni "MailRun" "MailRun" MailRun
  415.         profilerd OldIni "MailRun" "DownloadDir" DownloadDir
  416.         profilerd OldIni "MailRun" "UploadDir" UploadDir
  417.         profilerd OldIni "MailRun" "MailDir" MailDir
  418.         profilerd OldIni "MailRun" "ReplyDir" ReplyDir
  419.         profilerd OldIni "MailRun" "DialAttempts" DialAttempts
  420.         profilerd OldIni "MailRun" "DialTimeout" DialTimeout
  421.         profilerd OldIni "MailRun" "DialPause" DialPause
  422.         profilerd OldIni "MailRun" "IdleTimeout" IdleTimeout
  423.         profilerd OldIni "MailRun" "SavePackets" SavePackets
  424.         profilerd OldIni "MailRun" "LogRun" LogRun
  425.         profilerd OldIni "MailRun" "AppendLog" AppendLog
  426.         profilerd OldIni "MailRun" "AnsiInLog" AnsiInLog
  427.         profilerd OldIni "MailRun" "NewfileFilter" NewfileFilter
  428.         profilerd OldIni "MailRun" "Archiver" Archiver
  429.         profilerd OldIni "MailRun" "QWKReader" QWKReader
  430.         profilerd OldIni "MailRun" "LogViewer" LogViewer
  431.     else
  432.        ;otherwise, suggest default values based on current system settings
  433.     
  434.        fetch dialdir maxdial StateMaxDial
  435.        fetch dialdir waitcnct StateWaitCnct
  436.        fetch dialdir callpause StateCallPause
  437.        fetch dnldpath StateDLPath
  438.        fetch upldpath StateULPath
  439.         MailRun = "mailrun.mrn"
  440.        MailRunDir = makefullname($PWTASKPATH, "mailrun")
  441.        DownloadDir = StateDLPath
  442.        UploadDir = StateULPath
  443.        MailDir = StateDLPath
  444.        ReplyDir = StateULPath
  445.        itoa StateMaxDial DialAttempts
  446.        itoa StateWaitCnct DialTimeout
  447.        itoa StateCallPause DialPause
  448.        IdleTimeout = "120"
  449.        SavePackets = "3"
  450.        LogRun = 1
  451.        AppendLog = 0
  452.        AnsiInLog = 0
  453.        NewfileFilter = 0
  454.     endif
  455.  
  456.     if Version == 2.00
  457.         getbbstypes()
  458.     endif
  459.    MailRunList = "MAILRUN.INI"
  460.    MailRunTrunc = "MAILRUN.INI"
  461. endproc
  462.  
  463.  
  464. #comment
  465. *********************************************************************
  466. * GETBBSTYPES()
  467. * Called by makeini()
  468. * Adds any user created prompt sets from a previous version
  469. * of MailRun to MAILRUN.INI.
  470. *********************************************************************
  471. #endcomment
  472.  
  473. proc getbbstypes
  474. string BBSType_X, BBSType, MailDoor_X, MailDoorType, temp
  475. integer i, j
  476.     i = 1
  477.     j = 6
  478.     strfmt BBSType_X "BBSType_%d" i
  479.     profilerd OldIni "BBSTypes" BBSType_X BBSType
  480.     while not NULLSTR BBSType
  481.         switch BBSType
  482.             case "PCBoard 14.5"
  483.             case "WildCat! 3.5"
  484.             case "WildCat! 3.6"
  485.             case "Auntie"
  486.             case "RBBS"
  487.             endcase
  488.             default
  489.                 strfmt BBSType_X "BBSType_%d" j
  490.                 j++
  491.                 profilewr MailRunIni "BBSTypes" BBSType_X BBSType
  492.                 profilerd OldIni BBSType "MailDoorType" temp
  493.                 profilewr MailRunIni BBSType "MailDoorType" temp
  494.                 profilerd OldIni BBSType "LangPrompt" temp
  495.                 profilewr MailRunIni BBSType "LangPrompt" temp
  496.                 profilerd OldIni BBSType "GraphicsPrompt" temp
  497.                 profilewr MailRunIni BBSType "GraphicsPrompt" temp
  498.                 profilerd OldIni BBSType "NamePrompt" temp
  499.                 profilewr MailRunIni BBSType "NamePrompt" temp
  500.                 profilerd OldIni BBSType "PWordPrompt" temp
  501.                 profilewr MailRunIni BBSType "PWordPrompt" temp
  502.                 profilerd OldIni BBSType "Confirm1Prompt" temp
  503.                 profilewr MailRunIni BBSType "UserPrompt1" temp
  504.                 profilerd OldIni BBSType "Confirm2Prompt" temp
  505.                 profilewr MailRunIni BBSType "UserPrompt2" temp
  506.                 profilerd OldIni BBSType "ViewPrompt" temp
  507.                 profilewr MailRunIni BBSType "ViewPrompt" temp
  508.                 profilerd OldIni BBSType "ScanPrompt" temp
  509.                 profilewr MailRunIni BBSType "ScanPrompt" temp
  510.                 profilerd OldIni BBSType "FilePrompt" temp
  511.                 profilewr MailRunIni BBSType "FilePrompt" temp
  512.                 profilerd OldIni BBSType "MorePrompt" temp
  513.                 profilewr MailRunIni BBSType "MorePrompt" temp
  514.                 profilerd OldIni BBSType "ContinuePrompt" temp
  515.                 profilewr MailRunIni BBSType "ContinuePrompt" temp
  516.                 profilerd OldIni BBSType "CommandPrompt" temp
  517.                 profilewr MailRunIni BBSType "CommandPrompt" temp
  518.                 profilerd OldIni BBSType "DLPrompt" temp
  519.                 profilewr MailRunIni BBSType "DLPrompt" temp
  520.                 profilerd OldIni BBSType "DLUnavPrompt" temp
  521.                 profilewr MailRunIni BBSType "DLUnavPrompt" temp
  522.                 profilerd OldIni BBSType "ULPrompt" temp
  523.                 profilewr MailRunIni BBSType "ULPrompt" temp
  524.                 profilerd OldIni BBSType "ULDescPrompt" temp
  525.                 profilewr MailRunIni BBSType "ULDescPrompt" temp
  526.             endcase
  527.         endswitch
  528.         i++
  529.         strfmt BBSType_X "BBSType_%d" i
  530.         profilerd OldIni "BBSTypes" BBSType_X BBSType
  531.     endwhile
  532.     i = 1
  533.     j = 9
  534.     strfmt MailDoor_X "MailDoor_%d" i
  535.     profilerd OldIni "MailDoors" MailDoor_X MailDoorType
  536.     while not NULLSTR MailDoorType
  537.         switch MailDoorType
  538.             case "QMail"
  539.             case "MarkMail"
  540.             case "Cam-Mail"
  541.             case "RoseMail"
  542.             case "KingMail"
  543.             case "TomCat"
  544.             case "Auntie Mail"
  545.             case "Mail Manager"
  546.             endcase
  547.             default
  548.                 strfmt MailDoor_X "MailDoor_%d" j
  549.                 j++
  550.                 profilewr MailRunIni "MailDoors" MailDoor_X MailDoorType
  551.                 profilerd OldIni MailDoorType "MailDoor" temp
  552.                 profilewr MailRunIni MailDoorType "MailDoor" temp
  553.                 profilerd OldIni MailDoorType "MailPrompt" temp
  554.                 profilewr MailRunIni MailDoorType "MailPrompt" temp
  555.                 profilerd OldIni MailDoorType "ReceiveQWKPrompt" temp
  556.                 profilewr MailRunIni MailDoorType "ReceiveQWKPrompt" temp
  557.                 profilerd OldIni MailDoorType "MailDLPrompt" temp
  558.                 profilewr MailRunIni MailDoorType "MailDLPrompt" temp
  559.                 profilerd OldIni MailDoorType "MailULPrompt" temp
  560.                 profilewr MailRunIni MailDoorType "MailULPrompt" temp
  561.                 profilerd OldIni MailDoorType "MsgMenuPrompt" temp
  562.                 profilewr MailRunIni MailDoorType "MsgMenuPrompt" temp
  563.                 profilerd OldIni MailDoorType "QWKArchiver" temp
  564.                 profilewr MailRunIni MailDoorType "QWKArchiver" temp
  565.                 profilerd OldIni MailDoorType "MailXferProt" temp
  566.                 profilewr MailRunIni MailDoorType "MailXferProt" temp
  567.             endcase
  568.         endswitch
  569.         i++
  570.         strfmt MailDoor_X "MailDoor_%d" i
  571.         profilerd OldIni "MailDoors" MailDoor_X MailDoorType
  572.     endwhile
  573. endproc    
  574.  
  575.  
  576. #comment
  577. *********************************************************************
  578. * CHANGESETTINGS()
  579. * Called by main()
  580. * Calls checkdir(), settingsbox()
  581. * Allows the user to change the defaults in MAILRUN.INI.
  582. *********************************************************************
  583. #endcomment
  584.  
  585. proc changesettings
  586. string LastMRunDir, LastMailDir, LastReplyDir
  587. string LastDLDir, LastULDir
  588. string SaveMsg = "You have not saved your MailRun settings.  \
  589. Select `"OK`" to return, `"Cancel`" to abort MailRun."
  590. integer dialogstatus, savestatus
  591. integer Response
  592.    ;Save old values in case of error in directory creation
  593.    LastMRunDir = MailRunDir
  594.    LastMailDir = MailDir
  595.    LastReplyDir = ReplyDir
  596.    LastDLDir = DownloadDir
  597.    LastULDir = UploadDir
  598.    settingsbox()
  599.    disable CTRL 170
  600.    savestatus = 1
  601.    while 1
  602.       dialogstatus = $DIALOG
  603.       switch dialogstatus
  604.          case 10
  605.             ;User selected "Save"
  606.             ;if the directories chosen in settingsbox()
  607.             ;don't exist, create them
  608.                 if checkdir(&MailRunDir, LastMRunDir) && \
  609.                     checkdir(&MailDir, LastMailDir) && \
  610.                     checkdir(&ReplyDir, LastReplyDir) && \
  611.                     checkdir(&DownloadDir, LastDLDir) && \
  612.                     checkdir(&UploadDir, LastULDir)
  613.                ;if all directories exist or were successfully created
  614.                ;write the settings to MAILRUN.INI
  615.                chdir MailRunDir
  616.                profilewr MailRunIni "MailRun" "MailRunDir" MailRunDir
  617.                profilewr MailRunIni "MailRun" "MailDir" MailDir
  618.                profilewr MailRunIni "MailRun" "ReplyDir" ReplyDir
  619.                profilewr MailRunIni "MailRun" "DownloadDir" DownloadDir
  620.                profilewr MailRunIni "MailRun" "UploadDir" UploadDir
  621.                profilewr MailRunIni "MailRun" "DialAttempts" DialAttempts
  622.                profilewr MailRunIni "MailRun" "DialTimeout" DialTimeout
  623.                profilewr MailRunIni "MailRun" "DialPause" DialPause
  624.                profilewr MailRunIni "MailRun" "IdleTimeout" IdleTimeout
  625.                profilewr MailRunIni "MailRun" "SavePackets" SavePackets
  626.                profilewr MailRunIni "MailRun" "LogRun" LogRun
  627.                profilewr MailRunIni "MailRun" "AppendLog" AppendLog
  628.                profilewr MailRunIni "MailRun" "AnsiInLog" AnsiInLog
  629.                profilewr MailRunIni "MailRun" "NewfileFilter" NewfileFilter
  630.                profilewr MailRunIni "MailRun" "Archiver" Archiver
  631.                profilewr MailRunIni "MailRun" "QWKReader" QWKReader
  632.                profilewr MailRunIni "MailRun" "LogViewer" LogViewer
  633.             else
  634.                updatedlg 128
  635.                loopwhile
  636.             endif
  637.             savestatus = 0
  638.          endcase
  639.          case 11
  640.             ;User selected "Done"
  641.             if savestatus == 0
  642.                ;if settings have been saved, return to processing
  643.                exitwhile
  644.             endif
  645.             if savestatus == 1
  646.                ;if settings have not been saved, display a warning
  647.                sdlgmsgbox "MailRun Message" SaveMsg EXCLAMATION \
  648.                   OKCANCEL Response 1
  649.                switch Response
  650.                   case 1
  651.                      ;User selected "OK" to continue
  652.                      loopwhile
  653.                   endcase
  654.                   case 2
  655.                      ;User selected "Cancel" to abort
  656.                      delfile MailRunIni
  657.                      halt
  658.                   endcase
  659.                endswitch
  660.             endif
  661.          endcase
  662.          case 70
  663.             ;User selected the "Capture mailrun..." checkbox
  664.             if LogRun == 0
  665.                disable CTRL 71
  666.                disable CTRL 72
  667.             else
  668.                enable CTRL 71
  669.                enable CTRL 72
  670.             endif
  671.             savestatus = 1
  672.             updatedlg 1
  673.          endcase
  674.          case 230
  675.          case 231
  676.          case 232
  677.          case 233
  678.          case 234
  679.          case 235
  680.          case 236
  681.          case 237
  682.          case 238
  683.          case 239
  684.          case 240
  685.          case 241
  686.          case 242
  687.          case 71
  688.          case 72
  689.          case 73
  690.             savestatus = 1
  691.          endcase
  692.       endswitch
  693.    endwhile
  694. endproc
  695.  
  696.  
  697. #comment
  698. *********************************************************************
  699. * CHECKDIR()
  700. * Called by main(), changesettings()
  701. * Creates a directory.  Returns 1 if directory was successfully
  702. * created or already existed; returns 0 if an error ocurred in
  703. * creation.
  704. *********************************************************************
  705. #endcomment
  706.  
  707. func checkdir : integer
  708. strparm NewDir, OldDir
  709.     chdir NewDir
  710.     if FAILURE
  711.         mkdir NewDir
  712.         if FAILURE
  713.             usermsg "Unable to create directory %s" NewDir
  714.             NewDir = OldDir
  715.             return 0
  716.         endif
  717.     endif
  718.     return 1
  719. endfunc
  720.  
  721.  
  722. #comment
  723. *********************************************************************
  724. * MOVEDIR()
  725. * Called by main()
  726. * Calls makefullname(), movefiles()
  727. * Moves MailRun source files to the MailRun directory.
  728. *********************************************************************
  729. #endcomment
  730.  
  731. proc movedir
  732. string aspectpath, temp1, temp2
  733.    temp1 = makefullname(MailRunDir,"*") 
  734.    fetch aspect defaultpath aspectpath
  735.    temp2 = makefullname(aspectpath, "*")
  736.    if not strcmpi temp1 temp2
  737.         movefiles(aspectpath, MailRunDir, "MRUN210?.WA?")
  738.         movefiles(aspectpath, MailRunDir, "MRUN210.H")
  739.         movefiles(aspectpath, MailRunDir, "NEWFILES.WA?")
  740.         movefiles(aspectpath, MailRunDir, "TERMINAL.WA?")
  741.         movefiles(aspectpath, MailRunDir, "MRUNICON.DLL")
  742.         movefiles(aspectpath, MailRunDir, "MAILRUN.WRI")
  743.       statmsg ""
  744.    endif
  745. endproc
  746.  
  747.  
  748. #comment
  749. *********************************************************************
  750. * MOVEFILES()
  751. * Called by movedir()
  752. * Calls makefullname()
  753. * Moves all files matching a filespec from their current
  754. * location to a new directory.
  755. *********************************************************************
  756. #endcomment
  757.  
  758. proc movefiles
  759. strparm OldDir, NewDir, Spec
  760. string OldFile, NewFile, OldSpec
  761.     OldSpec = makefullname(OldDir, Spec)
  762.     findfirst OldSpec
  763.     while FOUND
  764.         if not strcmpi $FILENAME "MRUN210.WAS"
  765.             if not strcmpi $FILENAME "MRUN210.WAX"
  766.                statmsg "Moving %s" $FILENAME
  767.                 OldFile = makefullname(OldDir, $FILENAME)
  768.                 NewFile = makefullname(NewDir, $FILENAME)
  769.                 copyfile OldFile NewFile
  770.                 delfile OldFile
  771.             endif
  772.         endif
  773.         findnext
  774.     endwhile
  775. endproc
  776.  
  777.  
  778. #comment
  779. *********************************************************************
  780. * UPDATEMRN()
  781. * Called by main()
  782. * Calls makefullname(), checkfile()
  783. * Updates existing *.MRN files to MailRun 2.1 format.
  784. *********************************************************************
  785. #endcomment
  786.  
  787. proc updatemrn
  788. string filespec, mrnfile, BBSi, XferProt, BBS_X, BBSType
  789. string MailDoor, MailPrompt
  790. integer i
  791.    filespec = makefullname(MailRunDir, "*.MRN")
  792.    findfirst filespec
  793.    while FOUND
  794.       statmsg "Updating Mailrun %s" $FILENAME
  795.       mrnfile = makefullname(MailRunDir, $FILENAME)
  796.       profilewr mrnfile "MailRun" "DLPurgeLimit" 0
  797.       profilewr mrnfile "MailRun" "GoWait" 1
  798.       profilewr mrnfile "MailRun" "PostRun" 1
  799.       profilewr mrnfile "MailRun" "RingInterrupt" 1
  800.       i = 1
  801.       strfmt BBS_X "BBS_%d" i
  802.       profilerd mrnfile "MailRun" BBS_X BBSi
  803.          while not NULLSTR BBSi
  804.              profilerd mrnfile BBSi "BBSType" BBSType
  805.              if strcmpi BBSType "WildCat! 3.5"
  806.                  profilewr mrnfile BBSi "BBSType" "WildCat! 3.6"
  807.                  profilewr mrnfile BBSi "MsgMenuPrompt" "MESSAGE MENU"
  808.              endif
  809.            if checkfile(OldIni) && (Version != 2.00)
  810.                 profilewr mrnfile BBSi "BBSType" "PCBoard 14.5"
  811.                 profilewr mrnfile BBSi "ViewPrompt" "View"
  812.              profilerd mrnfile BBSi "XferProt" XferProt
  813.                 profilewr mrnfile BBSi "MailXferProt" XferProt
  814.                 profilerd mrnfile BBSi "MailDoor" MailDoor
  815.                 strfmt MailDoor "door;%s" MailDoor
  816.                 profilewr mrnfile BBSi "MailDoor" MailDoor
  817.                 profilerd mrnfile BBSi "MailPrompt" MailPrompt
  818.                 if strfind MailPrompt "QMail"
  819.                     profilewr mrnfile BBSi "MailDoorType" "QMail"
  820.                 elseif strfind MailPrompt "MarkMail"
  821.                     profilewr mrnfile BBSi "MailDoorType" "MarkMail"
  822.                 elseif strfind MailPrompt "Cam-Mail"
  823.                     profilewr mrnfile BBSi "MailDoorType" "Cam-Mail"
  824.                 elseif strfind MailPrompt "RoseMail"
  825.                     profilewr mrnfile BBSi "MailDoorType" "RoseMail"
  826.                 elseif strfind MailPrompt "KingMail"
  827.                     profilewr mrnfile BBSi "MailDoorType" "KingMail"
  828.                 endif
  829.               endif
  830.             i++
  831.             strfmt BBS_X "BBS_%d" i
  832.          profilerd mrnfile "MailRun" BBS_X BBSi
  833.          endwhile
  834.          findnext
  835.       endwhile
  836.       statmsg ""
  837. endproc
  838.       
  839.  
  840. #comment
  841. *********************************************************************
  842. * GETTEMPDIR()
  843. * Called by main()
  844. * Assigns the name of the MailRun temporary directory to
  845. * TempDir.
  846. *********************************************************************
  847. #endcomment
  848.  
  849. proc gettempdir
  850. string env
  851.    getenv "TEMP" env
  852.    if NULLSTR env
  853.       TempDir = $PWTASKPATH
  854.    else
  855.       TempDir = env
  856.    endif
  857.    addfilename TempDir "MRUNTEMP"
  858. endproc
  859.  
  860.  
  861. #comment
  862. *********************************************************************
  863. * CHECKFILE()
  864. * Called by main()
  865. * Checks for a file's existence.  Returns 1 if the file is
  866. * found, 0 if not found.
  867. *********************************************************************
  868. #endcomment
  869.  
  870. func checkfile : integer
  871. strparm FileNom
  872.    if isfile FileNom
  873.       return 1
  874.    else
  875.       return 0
  876.    endif
  877. endfunc
  878.  
  879.  
  880. #comment
  881. *********************************************************************
  882. * MAKEFULLNAME()
  883. * Called by various.
  884. * Appends a filename to a directory name.
  885. *********************************************************************
  886. #endcomment
  887.  
  888. func makefullname : string
  889. strparm Directory, FileNamen
  890. string FullName
  891.    FullName = Directory 
  892.    addfilename FullName FileNamen
  893.    return FullName
  894. endfunc
  895.  
  896.  
  897. #comment
  898. *********************************************************************
  899. * WELCOMEBOX()
  900. * Called by makeini()
  901. * Displays a dialog box to welcome first time users.
  902. *********************************************************************
  903. #endcomment
  904.  
  905. proc welcomebox
  906. HelpPage = 1
  907. dialogbox 80 57 198 125 15 "MailRun" HELPID HelpPage
  908.    text  10 11 178 8 center "Welcome to MailRun!"
  909.    text  21 26 156 63 center "Before you begin, you will need to \
  910. configure some basic system settings.  Default settings for MailRun \
  911. are stored in the file MAILRUN.INI, which may be manually edited.`r`n`r`n\
  912. Press F1 for Help."
  913.    pushbutton 49 95 40 14 "OK" normal
  914.    pushbutton 104 95 40 14 "Cancel" cancel
  915. enddialog
  916. endproc
  917.  
  918.  
  919. #comment
  920. *********************************************************************
  921. * SETTINGSBOX()
  922. * Called by changesettings()
  923. * Displays the MailRun Settings dialog box.
  924. *********************************************************************
  925. #endcomment
  926.  
  927. proc settingsbox
  928. HelpPage = 13
  929. dialogbox 15 36 340 222 15 "MailRun Settings" HELPID HelpPage
  930.    groupbox 10 28 200 96 "Directories" shadow
  931.    text  16 42 71 8 right "MailRun Directory:"
  932.    text  16 58 71 8 right "Mail Directory:"
  933.    text  16 74 71 8 right "Reply Directory:"
  934.    text  16 90 71 8 right "Download Directory:"
  935.    text  16 106 71 8 right "Upload Directory:"
  936.    editbox 91 56 110 12 MailDir
  937.    editbox 91 72 110 12 ReplyDir
  938.    editbox 91 88 110 12 DownloadDir
  939.    editbox 91 104 110 12 UploadDir
  940.    groupbox 224 28 102 96 "Parameters" shadow
  941.    text  234 42 62 8 right "Dial Attempts:"
  942.    text  234 58 62 8 right "Dial Timeout:"
  943.    text  234 74 62 8 right "Dial Pause:"
  944.    text  234 90 62 8 right "Idle Timeout:"
  945.    text  234 106 62 8 right "Packets to Save:"
  946.    editbox 300 40 16 12 DialAttempts
  947.    editbox 300 56 16 12 DialTimeout
  948.    editbox 300 72 16 12 DialPause
  949.    editbox 300 88 16 12 IdleTimeOut
  950.    editbox 300 104 16 12 SavePackets
  951.    groupbox 10 132 124 59 "Logging" shadow
  952.    checkbox 18 144 112 12 "Capture mailrun to log file" LogRun
  953.    checkbox 18 158 112 12 "Append to existing log file" AppendLog
  954.    checkbox 18 172 112 12 "Capture ANSI codes in log file" AnsiInLog
  955.    checkbox 18 200 134 12 "Filter duplicates from d/l database" NewfileFilter
  956.    groupbox 144 132 184 59 "Utilities" shadow
  957.    text  145 146 65 8 right "Archive Utility:"
  958.    text  145 160 65 8 right "QWK Mail Reader:"
  959.    text  145 174 65 8 right "Log File Viewer:"
  960.    editbox 214 144 107 12 Archiver
  961.    editbox 214 158 107 12 QWKReader
  962.    editbox 214 172 107 12 LogViewer
  963.    pushbutton 191 200 40 14 "&Save" normal default
  964.    pushbutton 252 200 40 14 "&Done" normal
  965.    text  100 11 52 8 right "Settings for:"
  966.    combobox 156 9 72 42 MailRunList MailRunTrunc sort
  967.    editbox 91 40 110 12 MailRunDir
  968. enddialog
  969. endproc
  970.  
  971.  
  972.  
  973.